cmake_minimum_required(VERSION 3.11)

project(AIPlus)

# TODO 从输入参数和系统获取
add_compile_definitions(AREA="${AREA}" BUILD_INFO="${BUILD_INFO}" BUILD_TS=${BUILD_TS} LOG_DEBUG_LEVEL=${LOG_DEBUG_LEVEL} YOLO_VERSION=${YOLO_VERSION} CLASS_NUM=${CLASS_NUM} LANDMARK_NUM=${LANDMARK_NUM})

set(DEPFLAGS "-MMD -MP")
# set(CMAKE_C_FLAGS "-g -Wall -O0 ${DEPFLAGS} ")

set(CMAKE_C_FLAGS "-O0 ${DEPFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=gnu++11 ${DEPFLAGS}")

# set(CMAKE_C_FLAGS "-O0 ${DEPFLAGS} -lgomp")
# set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=gnu++11 ${DEPFLAGS} -lgomp")

# set(CMAKE_C_FLAGS "-O0 ${DEPFLAGS} -fopenmp")
# set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=gnu++11 ${DEPFLAGS} -fopenmp")
# set(CMAKE_CXX_FLAGS "-std=gnu++11 -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math -fpermissive")

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE release CACHE STRING "Choose the type of build" FORCE)
endif()

# option 
option(HWAPP_HISI_SERVICE "Enable hisi service interface" ON)

message(STATUS ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
message(STATUS "\tLET'S GO")
message(STATUS "\tHW_APP BUILD INFO:")
message(STATUS "\tSystem: ${CMAKE_SYSTEM_NAME}")
message(STATUS "\tProcessor: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "\tCMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "\tHWAPP_BUILD_PLATFORM: ${HWAPP_BUILD_PLATFORM}")
message(STATUS "\tHWAPP_HISI_SERVICE: ${HWAPP_HISI_SERVICE}")
message(STATUS "\tBuild Path: ${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

include_directories(${PROJECT_SOURCE_DIR}/3rd_party/include/hisi)
include_directories(${PROJECT_SOURCE_DIR}/3rd_party/include/opencv)
include_directories(${PROJECT_SOURCE_DIR}/3rd_party/include/Eigen)
include_directories(${PROJECT_SOURCE_DIR}/3rd_party/include/freetype2)
include_directories(${PROJECT_SOURCE_DIR}/3rd_party/include/ncnn)
include_directories(${PROJECT_SOURCE_DIR}/3rd_party/include/sqlite3)
include_directories(${PROJECT_SOURCE_DIR}/3rd_party/include/MNN)
include_directories(${PROJECT_SOURCE_DIR}/3rd_party/include)

# 3516和3519的库是一样的
if (HWAPP_BUILD_PLATFORM MATCHES "3519" OR HWAPP_BUILD_PLATFORM MATCHES "3516") 
    SET(HWAPP_BUILD_PLATFORM "351X")
endif()

set(OpenCV_LIB_PATH ${PROJECT_SOURCE_DIR}/3rd_party/libopencv_${HWAPP_BUILD_PLATFORM}/)
link_directories(${OpenCV_LIB_PATH})
set(OpenCV_LIBS opencv_core opencv_highgui opencv_imgcodecs opencv_imgproc opencv_videoio)

set(HISI_LIB_PATH ${PROJECT_SOURCE_DIR}/3rd_party/hisi/lib)
link_directories(${HISI_LIB_PATH})

set(FREETYPE_LIB_PATH ${PROJECT_SOURCE_DIR}/3rd_party/libfreetype_${HWAPP_BUILD_PLATFORM}/)
link_directories(${FREETYPE_LIB_PATH})

set(NCNN_LIB_PATH ${PROJECT_SOURCE_DIR}/3rd_party/libncnn/)
link_directories(${NCNN_LIB_PATH})

set(SQLITE3_LIB_PATH ${PROJECT_SOURCE_DIR}/3rd_party/libsqlite3/)
link_directories(${SQLITE3_LIB_PATH})

set(SQLITE_CPP_LIB_PATH ${PROJECT_SOURCE_DIR}/3rd_party/libsqlite_cpp/)
link_directories(${SQLITE_CPP_LIB_PATH})

set(MNN_LIB_PATH ${PROJECT_SOURCE_DIR}/3rd_party/libmnn_${HWAPP_BUILD_PLATFORM}/)
link_directories(${MNN_LIB_PATH})

link_directories(${PROJECT_SOURCE_DIR}/3rd_party/libsecure_${HWAPP_BUILD_PLATFORM}/)

message(STATUS "OpenCV_LIB_PATH: ${OpenCV_LIB_PATH}")
message(STATUS "HISI_LIB_PATH: ${HISI_LIB_PATH}")
message(STATUS "FREETYPE_LIB_PATH: ${FREETYPE_LIB_PATH}")
message(STATUS "NCNN_LIB_PATH: ${NCNN_LIB_PATH}")
message(STATUS "SQLITE3_LIB_PATH: ${SQLITE3_LIB_PATH}")
message(STATUS "SQLITE_CPP_LIB_PATH: ${SQLITE_CPP_LIB_PATH}")
message(STATUS "MNN_LIB_PATH: ${MNN_LIB_PATH}")

include_directories(${PROJECT_SOURCE_DIR}/bytetracker/include)
aux_source_directory(${PROJECT_SOURCE_DIR}/bytetracker/src bytetracker_source)
include_directories(${PROJECT_SOURCE_DIR}/parking/include)
aux_source_directory(${PROJECT_SOURCE_DIR}/parking/src parking_source)
include_directories(${PROJECT_SOURCE_DIR}/lpr/include)
aux_source_directory(${PROJECT_SOURCE_DIR}/lpr/src lpr_source)
include_directories(${PROJECT_SOURCE_DIR}/lpr_ncnn/include)
aux_source_directory(${PROJECT_SOURCE_DIR}/lpr_ncnn/src lpr_ncnn_source)
include_directories(${PROJECT_SOURCE_DIR}/backend/mnn/include)
aux_source_directory(${PROJECT_SOURCE_DIR}/backend/mnn/src mnn_source)
include_directories(${PROJECT_SOURCE_DIR}/lpr_mnn/include)
aux_source_directory(${PROJECT_SOURCE_DIR}/lpr_mnn/src lpr_mnn_source)
include_directories(${PROJECT_SOURCE_DIR}/include)
aux_source_directory(${PROJECT_SOURCE_DIR}/src all_source)

add_subdirectory(example)